<template>
  <div class="home">
    <div class="scroll" ref="wrapper">
      <div>
        <h-swiper :list="slider"></h-swiper>
        <home-nav></home-nav>
        <div class=" module article_module">
          <div class="header">
            <div class="title_grp">
              <div class="title_icon" @click="aaa"></div>
              看文章
            </div>
            <router-link tag="div" class="get_more" to="/articleColumn">
              <span>查看更多 <span class="iconfont icon-getmore-icon"></span></span>
            </router-link>
          </div>
          <article-list :articleList="articleList"></article-list>
        </div>
        <div class="module test_module">
          <div class="header">
            <div class="title_grp">
              <div class="title_icon"></div>
              做测试
            </div>
            <router-link tag="div" class="get_more" to="/articleColumn">
              <span>查看更多 <span class="iconfont icon-getmore-icon"></span></span>
            </router-link>
          </div>
          <test-list :testList="testList"></test-list>
        </div>
        <div class="module fm_module">
          <div class="header">
            <div class="title_grp">
              <div class="title_icon"></div>
              听FM
            </div>
            <router-link tag="div" class="get_more" to="/psyFm">
              <span>查看更多 <span class="iconfont icon-getmore-icon"></span></span>
            </router-link>
          </div>
           <fm-list :fmListData="fmList"></fm-list>
        </div>

        <div class="null"></div>
      </div>
    </div>
  </div>
</template>

<script>
  import Bscroll from 'better-scroll'
  import HSwiper from 'components/swiper/swiper'
  import HomeNav from './components/nav'
  import ArticleList from 'components/articleList/articleList'
  import TestList from 'components/testList/testList'
  import FmList from './components/homeFmList'
  import {getArticleList} from "../../api/api";

  export default {
    name: 'Home',
    data() {
      return {
        slider: [],
        articleList: [],
        testList: [],
        fmList:[]
      }
    },
    created(){
      // this.getHomeInfo()
      this.getFm()
      this.getSlider()
      this._getArticleList()
    },
    mounted() {
      this.scroll = new Bscroll(this.$refs.wrapper,{
        click:true,
      })
    },
    methods: {
      aaa(){
        alert(1)
      },
      getHomeInfo() {
        this.axios.get('/api/index.json').then(this.getHomeInfoSucc)
      },
      getSlider(){
        this.axios.get('api/wxapp/homepage/getSlide?type=1').then((res)=>{
          this.slider = res.data.data
        })
      },
      _getArticleList(){
        getArticleList(0,0,3).then((res)=>{
          res =res.data
          this.articleList = res.data
        })
      },

      getFm(){
          this.$http.get(`/v1/restserver/ting?format=json&method=baidu.ting.billboard.billList&type=1&size=3&offset=0`).then((res)=>{
            // console.log(res.data.song_list)
            this.fmList = res.data.song_list
          })
      },

      getHomeInfoSucc(res) {
        res = res.data
        if (res.ret && res.data) {
          const data = res.data
          this.slider = data.slider
          this.articleList = data.articleList
          this.testList = data.testList
          this.fmList=data.fmListData
        }
      }
    },
    components: {
      HSwiper,
      HomeNav,
      ArticleList,
      TestList,
      FmList
    }
  }
</script>

<style scoped>
  .scroll {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
  }

  .slider-wrapper {
    width: 100%;
    height: 300px;
    position: relative;
    overflow: hidden;
  }

  .module {

  }

  .module .header {
    width: 100%;
    height: 90px;
    line-height: 90px;
    padding: 0 25px;
    border-bottom: solid 1px #e5e5e5;

  }

   .title_grp {
    width: 130px;
    float: left;
    font-size: 34px;
    font-weight: bold;
    color: black;
    position: relative;
  }

  .title_icon {
    width: 6px;
    height: 34px;
    border-radius: 3px;
    background: #059692;
    float: left;
    margin-top: 28px;
    margin-right: 20px;
  }

  .get_more {
    position: absolute;
    width: 150px;
    right: 10px;
    font-size: 24px;
    color: #c5c5c7;
    text-align: right;
  }

  .get_more .icon-getmore-icon {
    font-size: 36px;
    float: right;
  }

  .null{
    height: 100px;
  }

</style>
